package com.project.config;

import com.project.util.Interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    /**拦截 购买、订单 */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new Interceptor()).addPathPatterns("/shoppingCart/buy")
                .addPathPatterns("/order/findByItem").addPathPatterns("/order/showAll");
    }
    /**上传图片 */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/product/**")//访问路径
                .addResourceLocations("file:E:/mavenstudy/webShopping/src/img/");
    }
}
